const debounce = <T extends (...args: any) => any>(callback: T, timeMS: number) => {
	let timeoutId: any = null;
	return (...args: Parameters<T>) => {
		if (timeoutId) {
			clearTimeout(timeoutId);
			timeoutId = null;
		}
		timeoutId = setTimeout(() => callback(...(args as any)), timeMS);
	};
};

export { debounce };
